home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 412_01 / include / search.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-01  |  1.7 KB  |  51 lines

  1. /*                     SEARCH_
  2.  
  3.     The base class SEARCH_ defines a skeleton search class from
  4.     which the actual search classes such as DEPTH_GRAPH_ are
  5.     derived. This means that SEARCH_ should never (have to) be used
  6.     for direct derivation!
  7.  
  8.     Essentially, this class implements two linked lists of NODE_ *
  9.     objects: open and closed. Open contains nodes that are ready for
  10.     expansion and closed contains nodes that already have the expansion
  11.     procedure applied to them.
  12.  
  13.     Every class that is (indirectly!) derived from SEARCH_ must pass
  14.     the start node, goal node and the number of operators to the
  15.     constructor of SEARCH_ (or rather, to the search class derived from
  16.     SEARCH_).
  17.  
  18.     N.B. the objective of add() is to add a new node to the list
  19.     according to a specific strategy, it is used by those classes
  20.     that are directly derived from SEARCH_, like DEPTH_GRAPTH_ etc.
  21. */
  22.  
  23. #ifndef _search_H_
  24. #define _search_H_
  25.  
  26. #include <stdio.h>
  27. #include "object.h"
  28. #include "nodes.h"
  29. #include "list.h"
  30.  
  31. class SEARCH_
  32. {
  33.     public:
  34.         SEARCH_(NODE_ *start, NODE_ *goal, int numop);
  35.     virtual ~SEARCH_();
  36.  
  37.         void generate();     // starts search process 
  38.         NODE_ *solve();      // actual search engine in combination with add()
  39.         void print_sol(NODE_ *) const;      // prints solution
  40.  
  41.         virtual int add(NODE_ *) = 0;       // adds node to open 
  42.     private:
  43.         int num_op;                // number of operators to be used
  44.     NODE_ *goalnode;
  45.     protected:     // protected since several classes need access through add() 
  46.         SORTEDLIST_ open,
  47.                     closed;
  48. };
  49.  
  50. #endif
  51.